home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 04 Christian / ierule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-16  |  1.0 KB  |  57 lines

  1.  
  2.  
  3. #ifndef _IERULE_H_
  4. #define _IERULE_H_
  5.  
  6. #include <string>
  7.  
  8. class IE;
  9. class IEExec;
  10. class IEGoal;
  11.  
  12. class IERule
  13. {
  14.  
  15. friend IE;
  16. friend IEGoal;
  17.  
  18. public:
  19.  
  20.     enum RuleType
  21.     {
  22.         Goto,        // Goto rule   - if condition met, goes to new goal 
  23.         Gosub,        // Push rule   - if condition met, keeps current goal's 
  24.                     //               rules on a stack and goes to new goal
  25.         Return      // Return rule - if condition met, return to previous goal                  
  26.     };
  27.  
  28. public:
  29.  
  30.     IERule  ( IEExec * condition );
  31.     ~IERule ();
  32.  
  33.     void     setGoal ( IEGoal * goal );
  34.     void     setGoal ( char * name, char * lineInfo );
  35.  
  36.     IEGoal * getGoal ();
  37.  
  38.     void     setType ( RuleType type );
  39.  
  40.     const char * getName () { return m_name.c_str(); }
  41.  
  42.  
  43. private:
  44.  
  45.     std::string m_name;
  46.     std::string m_goalName;
  47.     std::string m_lineInfo;
  48.  
  49.     IEGoal * m_goal;
  50.     IEExec * m_condition;
  51.  
  52.     RuleType m_type;
  53.  
  54.     bool     m_fired; // flag for rule that has been fired (triggered)
  55. };
  56.  
  57. #endif